package com.duplicate;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

public class OccuranceInArray {
	private static void findDuplicateNumber(int arr[]) {
		
	    Set<Integer> hashSet = new HashSet<Integer>();

	    for(int i=0; i < arr.length; i++){
	        boolean unique = hashSet.add(arr[i]);
	        if(unique == false)
	            System.out.println("duplication " + arr[i]);
	    }      

	}
public static void main(String[] args) {
	int array[]={3,4,56,9,3,9};
	findDuplicateNumber(array);
	/*String array[]=new String[]{"A","B","C","A","B","D"};
	Map<String, Integer> map=new HashMap<String, Integer>();
	for(String str:array){
		if(map.containsKey(str)){
			map.put(str, map.get(str)+1);
		}else{
			map.put(str, 1);
		}
		int count=0;
		for(int repeateCount:map.values()){
			if(repeateCount>1){
				count++;
			}
		}
		System.out.println("arra "+count);
	}*/
}
}
